<template>
  <div class="app-container">
    <el-row>
      <el-col :span="24" class="top">
        <el-form :model="searchParams" ref="searchParams" :inline="true">
          <el-form-item label="关联订单">
            <el-input class="input" v-model="searchParams.orderId" maxlength='20' placeholder="请输入" clearable
              show-word-limit></el-input>
          </el-form-item>
          <el-form-item label="用户ID">
            <el-input class="input" v-model="searchParams.userCode" maxlength='20' placeholder="请输入" clearable
              show-word-limit></el-input>
          </el-form-item>
          <el-form-item>
            <el-button @click="handleSearch" type="primary" icon="el-icon-search"
              style="margin-left:40px">搜索</el-button>
          </el-form-item>
        </el-form>
        <el-form :model="searchParams" ref="searchParams" :inline="true" style="margin:10px 0">
        </el-form>
        <el-table :data="dataList" size='medium' ref="multipleTable" @selection-change="handleSelectionChange" border>
          <el-table-column type="selection" width="55"></el-table-column>
          <el-table-column prop="id" label="id" width="50" show-overflow-tooltip></el-table-column>
          <el-table-column prop="createTime" label="记录时间" width="160">
            <template slot-scope="{row, index}">
              {{ formatTime.dateFormat('YY-MM-DD hh:mm:ss', row.createTime) }}
            </template>
          </el-table-column>
          <el-table-column prop="lesseeModel.name" label="租户" show-overflow-tooltip
            v-if="$store.getters.role == 'admin'"></el-table-column>
          <el-table-column prop="userModel.code" label="用户ID" show-overflow-tooltip></el-table-column>
          <el-table-column prop="money" label="提现金额" show-overflow-tooltip></el-table-column>
          <el-table-column prop="serviceCharge" label="手续费" show-overflow-tooltip></el-table-column>
          <el-table-column prop="realMoney" label="实际到账" show-overflow-tooltip></el-table-column>
          <el-table-column prop="payWayAccountModel.types" label="收款账户" show-overflow-tooltip></el-table-column>
          <el-table-column prop="redact" label="处理状态" fixed="right" width="120">
            <template slot-scope="{ row, index }">
              <div><el-tag type="danger" v-if="row.orderStatus == 'WAIT_SEND'">待处理</el-tag></div>
              <div><el-tag type="success" v-if="row.orderStatus == 'FINISH'">已发放</el-tag></div>
              <div v-if="row.orderStatus == 'REFUSE'">
                <el-tag type="info">已拒绝</el-tag>
                <div>拒绝原因：{{ row.remark }}</div>
              </div>
            </template>
          </el-table-column>
          <el-table-column prop="redact" label="操作" fixed="right" width="120">
            <template slot-scope="{ row, index }">
              <el-button type="text" @click="operateAction('handleOutMoney', row)" size='medium' v-if="row.orderStatus=='WAIT_SEND'">处理</el-button>
            </template>
          </el-table-column>
        </el-table>
        <pagination style="background: #ffffff; height: 50px" v-show="totalSize > 0" :total="totalSize"
          :page.sync="page" :limit.sync="size" @pagination="getDataList" />
      </el-col>
    </el-row>
    <handleUpdate ref="handleUpdate" @confirm='getDataList'></handleUpdate>
  </div>
</template>

<script>
import { formData } from './data'
import { findRecordIncomesList, deleteRecordIncomess } from '@/api/pay/recordIncomes.js'
import handleUpdate from './components/handleUpdate.vue'
export default {
  components: { handleUpdate },
  data() {
    return {
      page: 1,
      size: 10,
      totalSize: 0,
      dataList: [],
      searchParams: {},
      multipleSelection: [],
      formData

    }
  },
  created() {
    this.getDataList()
  },
  methods: {
    handleSearch() {
      this.page = 1
      this.getDataList()
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    operateAction(scene, row) {
      switch (scene) {
        case 'handleOutMoney':
          this.$refs.handleUpdate.show(row)
          break;
        default:
          break;
      }
    },
    //数据请求-----------------------------------------------
    // 获取列表数据
    getDataList() {
      this.searchParams.page = this.page
      this.searchParams.size = this.size
      this.searchParams.scene = 'outMoney'
      findRecordIncomesList(this.searchParams).then(res => {
        if (res.data.code == 10000) {
          this.totalSize = res.data.data.total_count
          this.dataList = res.data.data.list
        }
      });
    }
  },
}
</script>


<style lang="scss" scoped></style>
